package com.Wu.costomer.service;

import com.Wu.costomer.dao.CustomerDao;
import com.Wu.costomer.model.Customer;

public class CustomerService {
    /** 根据账号密码返回会员信息- 登录*/
    public Customer login(String username,String password) {
        CustomerDao dao = new CustomerDao();
       Customer customer =dao.getCustomerByName(username);
       if(customer != null) {
          if (username.equals(customer.getUser_name()) && password.equals(customer.getPassword())) {}
                return customer;
       }
        return null;
    }

    public boolean register(String username,String password) {
        if (username == null||"".equals(username)||password == null||"".equals(password)) {
            return false;
        }
        CustomerDao dao = new CustomerDao();
        //调用Dao层的逻辑进行会员注册
        int result=dao.addCustomer(username,password);
        //返回注册结果：true or false
        return result > 0;
    }
}
